<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	var clickTreeId = "";
	function departmentTree_onNodeClick(event, treeId, treeNode) {
		//alert(treeNode.treenodePath);
		//alert(	JSON.stringify(treeNode));
		/**/
	}
	function reloadDepartmentTree() {
		window.location.reload();
	}
	function nameFormatter(cellvalue, gender) {
		if (gender == '男')
			return "<img src='img/icons/packs/fugue/24x24/user-business.png'>" + cellvalue;
		else
			return "<img src='img/icons/packs/fugue/24x24/user-female.png'>" + cellvalue;

	}
	function restUserPassword() {
		var row = deptmentUserGrid.getRowData();
		if (!row) {
			isperp.alert("请选择一条用户数据！");
			return;
		}
		isperp.confirmAlert("您确定要重置用户【" + row.fullname + "】的密码为 123456 吗？", {
			yes : function() {
				$.post("app/user/restPassword/" + row.id, function() {
					isperp.tooltip("用户【" + row.fullname + "】密码已经重置为：123456！");
				});
			}
		});

	}
</script>

<table class="box col-table">

	<tr>
		<td class="col-three-one"><isperp:tree title="" modal="false" showLv1DeleteBtn="false"
				afterActionsSuccess="function c(){reloadDepartmentTree();}"
				id="departmentTree" cusEditUrl="app/department/edit?type=${ctype }"
				cusDeleteUrl="app/department/delete">
				<isperp:async enable="true" autoParam="'id'"
					otherParam="{asyncLoad:0}"
					url="app/department/getDeptTree?type=${ctype }&parentId=${pid}">
				</isperp:async>
				<isperp:edit enable="true" showRemoveBtn="false"
					showRenameBtn="false"></isperp:edit>
				<isperp:view showTitle="false" addHoverDom="true"
					removeHoverDom="true"></isperp:view>
			</isperp:tree></td>
		</td>
	</tr>
</table>
<section id="mainContent" class="frame-main-cont frame-main-cont-first"
	role="main">
	<div id="dvContainer">
		<isperp:grid gridId="deptmentUserGrid" 
			url="app/user/deptmentUser?type=customer&customerId=${pid }" gridTitle="人员"
			pager="userPager" cusFormatterActions="true"
			editOrDeleteRightControl="true" 
			cusEditUrl="app/user/edit?type=customer&deptId=${pid}" cusDialogSize="big"
			sortname="code"  showSearchbar="false"
			ondbClickRowEvent="deptmentUserGrid.edit(rowid);" actionsWidth="70"
			cusDeleteUrl="app/user/delete" >
			<jsp:attribute name="toolbar">
				<isperp:toolbar id="userToolbar">
				    <!--114是供应商窗口数据级别-->
					<isperp:button id="userCreate" icon="icon-plus" text="新增人员"
						cssClass="nui-mainbtn" onclick="deptmentUserGrid.create();"></isperp:button>
					<isperp:button icon="icon-cog" text="重置密码"
						onclick="restUserPassword();"></isperp:button>	
				</isperp:toolbar>
				</jsp:attribute>

			<jsp:attribute name="searchbar">
				<table class="search-table">
					<tbody>
						<tr style="height:40px;">
								<td align="right">关键字：</td>
								<td align="left"><input type="text" style="width:180px;"
								field="name,fullname,email,mobile,position,tel,memo" op="cn"> (可按姓名、邮件、职务、手机、电话、备注查询)
								
								<input type="text" style="width:180px;display:none" id="hid_deptPath" 
								field="department_treenode_path" op="bw">
								</td>
								
							</tr>
					</tbody>
				</table>
				</jsp:attribute>
			<jsp:body>	
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				<isperp:column name="gender" title="性别" width="50" hidden="true">
				</isperp:column>
				<isperp:column name="" title="姓名" isFormatterFun="true"
					formatter="return nameFormatter(rowObject.fullname,rowObject.gender);"
					width="90">
				</isperp:column>
				<isperp:column name="fullname" title="姓名" hidden="true" width="50">
				</isperp:column>
				<isperp:column name="name" title="用户帐号" width="90">
				</isperp:column>
				<isperp:column name="position" title="职务" width="60">
				</isperp:column>
				<isperp:column name="mobile" title="手机" width="80">
				</isperp:column>
		
				<isperp:column name="department_name" title="所在部门" width="100">
				</isperp:column>
				<isperp:column name="enable" title="有效" width="60"
					isFormatterFun="true"
					formatter="return isperp.statusFormatter(cellvalue);">
				</isperp:column> 
				</jsp:body>

		</isperp:grid>
	</div>
</section>



